package com.tea.funct.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tea.common.annotation.Log;
import com.tea.common.core.controller.BaseController;
import com.tea.common.core.domain.AjaxResult;
import com.tea.common.enums.BusinessType;
import com.tea.funct.domain.TeaFixation;
import com.tea.funct.service.ITeaFixationService;
import com.tea.common.utils.poi.ExcelUtil;
import com.tea.common.core.page.TableDataInfo;

/**
 * 静态配置Controller
 * 
 * @author Sophia
 * @date 2024-06-06
 */
@RestController
@RequestMapping("/funct/fixation")
public class TeaFixationController extends BaseController
{
    @Autowired
    private ITeaFixationService teaFixationService;

    /**
     * 查询静态配置列表
     */
    @PreAuthorize("@ss.hasPermi('funct:fixation:list')")
    @GetMapping("/list")
    public TableDataInfo list(TeaFixation teaFixation)
    {
        startPage();
        List<TeaFixation> list = teaFixationService.selectTeaFixationList(teaFixation);
        return getDataTable(list);
    }

    /**
     * 导出静态配置列表
     */
    @PreAuthorize("@ss.hasPermi('funct:fixation:export')")
    @Log(title = "静态配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeaFixation teaFixation)
    {
        List<TeaFixation> list = teaFixationService.selectTeaFixationList(teaFixation);
        ExcelUtil<TeaFixation> util = new ExcelUtil<TeaFixation>(TeaFixation.class);
        util.exportExcel(response, list, "静态配置数据");
    }

    /**
     * 获取静态配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('funct:fixation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(teaFixationService.selectTeaFixationById(id));
    }

    /**
     * 新增静态配置
     */
    @PreAuthorize("@ss.hasPermi('funct:fixation:add')")
    @Log(title = "静态配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeaFixation teaFixation)
    {
        return toAjax(teaFixationService.insertTeaFixation(teaFixation));
    }

    /**
     * 修改静态配置
     */
    @PreAuthorize("@ss.hasPermi('funct:fixation:edit')")
    @Log(title = "静态配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeaFixation teaFixation)
    {
        return toAjax(teaFixationService.updateTeaFixation(teaFixation));
    }

    /**
     * 删除静态配置
     */
    @PreAuthorize("@ss.hasPermi('funct:fixation:remove')")
    @Log(title = "静态配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(teaFixationService.deleteTeaFixationByIds(ids));
    }
}
